var gonggao=localStorage.getItem("gonggao");
var gimg=localStorage.getItem("gimg");
function MainScene(){
           var self=this;
           this.$me = $("<div class='mainscene'></div>");
           this.$but1 = $("<div id='shop' class='mainscene1' ></div>");
           this.$but2 = $("<div id='paly' class='mainscene2' ></div>");
           this.$but3 = $("<div id='about' class='mainscene3'></div>");
           this.$but4=$("<div class='outlogin' ></div>");
           this.$me.append(this.$but1);
           this.$me.append(this.$but2);
           this.$me.append(this.$but3);
           this.$me.append(this.$but4);

           this.$but1.click(function(){
               director.runScene(new ShopScene());


           });
           this.$but2.click(function(){
               director.runScene(new ScheduleScene());


           });
           this.$but3.click(function(){
               director.runScene(new Jam());
               $("#jam").fadeIn(300 ,function(){
                   $("#jam1").animate({top:"40%"})
               });


           });
           //退出
           this.$but4.click(function(){

               director.runScene(new Tuichu());

           });
           var jsonobj1={"handleid":13}; 
           $.ajax({
            type:"post",
            url:"handle/handout.php",
            dataType:"json",
            data:jsonobj1,
            success:function(data){
              //错误的情况
              //alert(data);
              if(data['rs']=='error'){
                console.log("gonggao"+data['rs']);
                return ;
              }     
              //正确的情况
              if(data['rs']=='success'){
                console.log("gonggao"+data['rs']);
                var $gonggao=$("<button class='wan'></button>");
                self.$me.append($gonggao);
                var $gonggaoq=$("<div class='wanq'></div>");
                self.$me.append($gonggaoq);
                 $gonggao.fadeIn(300 ,function(){
                         $gonggao.animate({top:"20%"});
                         $gonggaoq.animate({top:"18%"});
                     });
                    //关闭
                $gonggaoq.click(function(){
                        $gonggao.fadeOut(100);
                        $gonggaoq.fadeOut(100);
                });
                $gonggao.html("公告<br><span style='font-size: 22px;'>"+data['gongao']+"</span><br><div style='height:100px;width:100px;background:url("+data['gimg']+"); background-size:contain;margin-left: 91px;'></div>");
               }
              },
            error:function(responexml,name){
              console.log("gonggao"+name);
            }
          }); 
         
        }

//退出登录
function Tuichu(){
    this.$me=$("<div class='dajing'></div>");
    this.$jing=$("<div class='jing'>您确定退出？</div>");
    this.$but5=$("<button class='jingbut'>确定</button>");
    this.$but6=$("<button class='jingbut'>不确定</buttonstyle>");
    this.$me.append(this.$jing);
    this.$jing.append(this.$but5);
    this.$jing.append(this.$but6);
    this.$but5.click(function(){
        director.runScene(new LoginScene());
    });
    this.$but6.click(function(){
        director.runScene(new MainScene());
    });
}
//帮助文档
function Jam(){
    this.$me=$("<div id='jam'></div>");
    var $jam1=$("<div id='jam1'><br><br><br><br><br><br><br>并没有什么帮助<br>作者连育珊</div>");
    this.$me.append($jam1)
    //返回按钮
    this.$but=$("<a href='#' id='retur'  class='retur' ></a>");
    this.$me.append(this.$but);
    this.$but.click(function(){
        director.runScene(new MainScene());
    });
}
